<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>字典管理</title>
		[#include "/html/include/easyuicss.html" /]
		[#include "/html/include/easyuijs.html" /]
		<script type="text/javascript" src="${app }/static/js/common.utils.js"></script>
	</head>
	<body class="easyui-layout" data-options="fit:true" style="overflow-y: hidden">
	<table id="dictdg" class="easyui-datagrid" title="字典信息" style="width:100%;height:100%;">
		<thead>
		<tr>
			<th data-options="field:'group_id',width:200">字典组编码</th>
			<th data-options="field:'group_name',width:180">字典组名称</th>
			<th data-options="field:'group_desc',width:220">字典描述</th>
			<th data-options="field:'modify_time',width:180">操作时间</th>
			<th data-options="field:'operating',width:80,formatter:getBtn">操作</th>
		</tr>
		</thead>
	</table>
	<div id="tb">
		<span>字典组编码:</span>
		<input  class="easyui-textbox" id="groupId" name="groupId" />
		<span>字典组名称:</span>
		<input  class="easyui-textbox" id="groupName" name="groupName" />
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="searchDict();">查询</a>
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="parent.easyui.createWindow('字典新增', '${app}/sysmgr/dict/edit.do?method=create', '600px', '450px', window.name);">新增</a>
	</div>
	</body>
    <script type="text/javascript">
		$(document).ready(function(){
			$('#dictdg').datagrid({
				url: '${app}/sysmgr/dict/list.do',
				method: 'post',
				queryParams: {groupId: $('#groupId').val(), groupName: $('#groupName').val()},
				singleSelect: true,
                fitColumns: true,
				toolbar: '#tb',
				onLoadSuccess: onLoadSuccess,
				pagination: true,
				pageSize: 20,
				pageList: [10,20,30]
			});
		});
		function getBtn(value, row, index) {
			return '<a href="javascript:;" class="easyui-linkbutton" onclick="deleteDict(\''+row.group_id+'\')">删除</a>&nbsp;'+
					'<a href="javascript:;" class="easyui-linkbutton" onclick="parent.easyui.createWindow(\'字典修改\', \'${app}/sysmgr/dict/edit.do?method=edit&groupId='+row.group_id+'\', \'600px\', \'450px\', window.name);">编辑</a>&nbsp;';
		}
		function onLoadSuccess(data){
			$('.easyui-linkbutton').linkbutton();
		}
		function searchDict(){
			$('#dictdg').datagrid('load', {
				groupId: $('#groupId').val(),
				groupName: $('#groupName').val()
			});
		}
		function reloadDict(){
			$('#dictdg').datagrid('reload');
		}
		function deleteDict(groupId){
			parent.easyui.confirm('系统提醒', '您确定要删除该条记录吗？', function(r){
				if (r){
					parent.layer.load(2);
					common.ajax('${app}/sysmgr/dict/delete.do', 'groupId='+groupId,
						'POST', 'json', false,
						function(result){
							parent.layer.closeAll('loading');
							parent.easyui.msgShow('系统提醒', result.msg, 3000, 250, 100);
							if (result.result == 1) {
								reloadDict();
							}
						}
					);
				}
			});
		}
    </script>
</html>